<?php
/**
 * Copyright (c) Sandeep Manne (sandeep.manne@gmail.com) 
 *
 * @author  Sandeep Manne
 * @since   24-May-2009, 11:08:11 AM
 * @version $
 */

/**
 * @see Core_DAO
 */
require_once "Core/DAO.php";

class ZoneDAO extends Core_DAO
{
    protected $_name    = "zones";
    
    protected $_primary = "zone_id";

    /**
     * Save Zone data 
     * @param $zoneData
     * @return int primary key
     */
    public function addZone($zoneData)
    {
        return $this->insert($zoneData);
    }
    
    /**
     * Get all Zones
     * @return array zones
     */
    public function getZones()
    {
        return $this->select()
                    ->from($this->_name)
                    ->query()
                    ->fetchAll();
    }
    
    /**
     * Deletes Zone Data	
     * @param $zoneId
     * @return int Number of rows deleted
     */
    public function deleteZone($zoneId)
    {
        $where = $this->getDefaultAdapter()
                      ->quoteInto('zone_id = ?',  $zoneId);
             
        return $this->delete($where);
    }
    
    /**
     * Edit zone data
     * @param $zoneId
     * @param $zoneName
     * @return int Number of rows updated
     */
    public function editZone($zoneId, $zoneName)
    {
        $where = $this->getDefaultAdapter()
                      ->quoteInto('zone_id = ?',  $zoneId);
        
        return $this->update(array('zone_name' => $zoneName), $where);
    }
}
